package com.cloud_sang.fubai.service.impl;

import com.cloud_sang.fubai.dao.PaymentDao;
import com.cloud_sang.entity.CommonResult;
import com.cloud_sang.entity.Payment;
import com.cloud_sang.fubai.service.PaymentService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @ClassTitle: PaymentServiceImpl
 * @ProjectName springcould2020
 * @Description:
 * @Author Sangsang
 * @Date 2020/9/9
 * @Time 11:13
 */
@Service
public class PaymentServiceImpl implements PaymentService {
	@Resource
	private PaymentDao paymentDao;

	@Value("${server.port}")
	private String serverPort;

	@Override
	public CommonResult create(Payment payment) {
		int insert = paymentDao.insert(payment);
		if (insert > 0) {
			return new CommonResult(200, "创建成功，端口为："+serverPort,payment);
		} else {
			return new CommonResult(500, "创建失败，端口为："+serverPort);
		}

	}

	@Override
	public CommonResult<Payment> getPaymentById(Long id) {
		Payment payment = paymentDao.selectByPrimaryKey(id);
		if (payment != null) {
			return new CommonResult(200, "查询成功，端口为："+serverPort, payment);

		} else {
			return new CommonResult(500, "数据为空，id为：" + id+"，端口为："+serverPort);

		}
	}
}
